﻿$(document).ready(function () {
    activeMenu();

    hideContentSearch();
    fadeContentSearch();
});

function activeMenu() {
    var menu = $('#navigation a');
    menu.removeClass('active');

    menu.each(function () {
        if (window.location.href.indexOf(this.href) >= 0) {
            $(this).addClass('active');
        }
    });
}

function hideContentSearch() {
    var activeSearchForm = parseInt($("#ContentPlaceHolder1_hdfActiveSearch").val());
    if (activeSearchForm === 0) {
        $('#contentSearch').hide();
        $('#activeSearch').val('Tìm kiếm');
    } else {
        $('#activeSearch').val('Ẩn tìm kiếm');
    }
}

function fadeContentSearch() {
    $('#activeSearch').click(function () {
        var activeSearchForm = parseInt($("#ContentPlaceHolder1_hdfActiveSearch").val());
        if (activeSearchForm == 1) {
            $('#contentSearch').fadeOut();
            $('#activeSearch').val('Tìm kiếm');
            $("#ContentPlaceHolder1_hdfActiveSearch").val("0");
        } else {
            $('#contentSearch').fadeIn();
            $('#activeSearch').val('Ẩn tìm kiếm');
            $("#ContentPlaceHolder1_hdfActiveSearch").val("1");
        }
    });
}